Expression-oriented programming language
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
top
An expression-oriented programming language is a programming language in which every (or nearly every) construction is an expression and thus yields a value.cite-ref-1[1] The typical exceptions are macro definitions, preprocessor commands, and declarations, which expression-oriented languages often treat as statements.
All functional programming languages are expression-oriented.cite-ref-3[3]
Contents
• Examples
• See also
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
Criticism and prevention
Critics, including language designers,cite-ref-4[4] blame expression-orientation for an entire class of programming mistakes wherein a programmer accidentally codes an assignment expression, which replaces a variable with an expression rather than testing it for equality with that expression.
The designers of Ada and Java prevent this type of mistake by restricting control expressions to those that evaluate strictly to the boolean data type.cite-ref-5[5]cite-ref-6[6]
In some expression-oriented languages, expressions that merely cause side effects return void types.
Examples
See also
References
cite-note-11. ↑ "Glossary - The Rust Programming Language". web.mit.edu. Retrieved 2022-07-06.
cite-note-33. ↑ citerefknoldus2018Knoldus (2018-02-08). "Expression Oriented Programming". Knoldus – Technical Insights. Retrieved 2023-08-07.
cite-note-44. ↑ Java Code Conventions "10.4 Variable Assignments"
cite-note-55. ↑ The Java Language Specification, Java SE 8 Edition "14.9 The if Statement"
cite-note-66. ↑ Introducing Ada
cite-note-77. ↑ The Python Language Reference "6.2. Assignment statements"
cite-note-88. ↑ "PEP 572: Assignment Expressions"
cite-note-99. ↑ "Functions - The Rust Programming Language". web.mit.edu. Retrieved 2022-07-06.
cite-note-1010. ↑ "COS 326: Functional Programming". www.cs.princeton.edu. Retrieved 2022-07-06.